One approach might be to have a Virtual bit select the active Spindle. Two MCodes might be configured to select the active Spindle from within GCode. Two User Buttons might also be configured to easily select the Spindle.
Your Spindle C code would then check the Virtual Bit to determine which Spindle to Drive and so forth.
The Spindle Control code is handled differently for Mach3 and KMotionCNC. For KMotionCNC 4 different programs are required. One each for M3, M4, M5, and S. With Mach3 only one program is required but the program must decode the message to determine which function it should perform.
HTH
Regards
TK